return NULL;
}
+/**
+ * shell_app_system_lookup_wmclass:
+ * @system: a #ShellAppSystem
+ * @wmclass: A WM_CLASS value
+ *
+ * Find a valid application corresponding to a WM_CLASS value.
+ *
+ * Returns: (transfer none): A #ShellApp for @wmclass
+ */
+ShellApp *
+shell_app_system_lookup_wmclass (ShellAppSystem *system,
+ const char *wmclass)
+{
+ char *canonicalized;
+ char *desktop_file;
+ ShellApp *app;
+
+ if (wmclass == NULL)
+ return NULL;
+
+ canonicalized = g_ascii_strdown (wmclass, -1);
+
+ /* This handles "Fedora Eclipse", probably others.
+ * Note g_strdelimit is modify-in-place. */
+ g_strdelimit (canonicalized, " ", '-');
+
+ desktop_file = g_strconcat (canonicalized, ".desktop", NULL);
+
+ app = shell_app_system_lookup_heuristic_basename (system, desktop_file);
+
+ g_free (canonicalized);
+ g_free (desktop_file);
+
+ return app;
+}
+
/**
* shell_app_system_get_all:
* @system:
G_TYPE_NONE, 0);
}
-/**
- * get_appid_from_window:
- *
- * Turn the WM_CLASS property into our best guess at a .desktop file id.
- */
-static char *
-get_appid_from_window (MetaWindow *window)
-{
- const char *wmclass;
- char *appid_guess;
-
- wmclass = meta_window_get_wm_class (window);
- if (!wmclass)
- return NULL;
-
- appid_guess = g_ascii_strdown (wmclass, -1);
-
- /* This handles "Fedora Eclipse", probably others.
- * Note g_strdelimit is modify-in-place. */
- g_strdelimit (appid_guess, " ", '-');
-
- return appid_guess;
-}
-
/**
* shell_window_tracker_is_window_interesting:
*
return TRUE;
}
-/**
- * get_app_from_window_wmclass:
- *
- * Looks only at the given window, and attempts to determine
- * an application based on WM_CLASS. If one can't be determined,
- * return %NULL.
- *
- * Return value: (transfer full): A newly-referenced #ShellApp, or %NULL
- */
-static ShellApp *
-get_app_from_window_wmclass (MetaWindow *window)
-{
- ShellApp *app;
- ShellAppSystem *appsys;
- char *wmclass;
- char *with_desktop;
-
- appsys = shell_app_system_get_default ();
- wmclass = get_appid_from_window (window);
-
- if (!wmclass)
- return NULL;
-
- with_desktop = g_strjoin (NULL, wmclass, ".desktop", NULL);
- g_free (wmclass);
-
- app = shell_app_system_lookup_heuristic_basename (appsys, with_desktop);
- if (app != NULL)
- g_object_ref (app);
- g_free (with_desktop);
-
- return app;
-}
-
/**
* get_app_from_window_group:
* @monitor: a #ShellWindowTracker
get_app_for_window (ShellWindowTracker *tracker,
MetaWindow *window)
{
+ ShellAppSystem *app_system;
ShellApp *result = NULL;
const char *startup_id;
+ app_system = shell_app_system_get_default ();
+
/* First, we check whether we already know about this window,
* if so, just return that.
*/
/* Check if the app's WM_CLASS specifies an app; this is
* canonical if it does.
*/
- result = get_app_from_window_wmclass (window);
+ result = shell_app_system_lookup_wmclass (app_system,
+ meta_window_get_wm_class (window));
if (result != NULL)
return result;